const fs = require('fs')
const path = require('path')
const ExcelJS = require('exceljs');
const lodash = require('lodash')


module.exports=async (filepathAndFileName,worksheetName)=>{
    const workbook = new ExcelJS.Workbook();
    await workbook.xlsx.readFile(filepathAndFileName);
    const worksheet = workbook.getWorksheet(worksheetName);
    const myJson = [];
    const rows = worksheet.getRows(0, 327)
    rows.map(row => {
        // console.log('row', row.values)
        if (row.values.length > 0) {
           /* if (row.values[1] != '序号') {
                var name=row.values[4];
                if(name.richText instanceof  Array){
                    //如果是数组 处理第一个
                    name=name.richText[0].text
                }else{
                    if(name.richText){
                        name=name.richText
                    }
                }

                /!* var one = {
                   序号: row.values[1],
                   大类: row.values[2],
                   分类: row.values[3],
                   展商名称: name,
                   展位号: row.values[5],
               }*!/

            }*/

            if(row&&row.values[1]){
                let one = {
                    类别: row.values[1],
                    线上展联系人: row.values[2],
                    联系人手机号: row.values[3],
                    所属人: row.values[4],
                    公司名: row.values[5],
                    展位号: row.values[6],
                    关键词摘取: row.values[7],
                }
                myJson.push(one)
            }
        }
    })
    return myJson;
}